<%
var title= isEmpty(userAccount.id)?"新增":"编辑";
layout("/common/layout.html",{"title":title+"新闻"}){
%>
<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-sm-8">
        <h2>${title}</h2>
        <ol class="breadcrumb">
            <li><a href="${ctxPath}/admin/main">主页</a></li>
            <li><a href="${ctxPath}/itemInfo/view/index">新闻发布管理</a></li>
            <li class="active">${title}</li>
        </ol>
    </div>
    <div class="col-sm-4">
        <div class="title-action">
            <a class="btn btn-primary btn-sm btn-outline" href="${ctxPath}/itemInfo/view/index">
                <i class="fa fa-reply"> </i> 返回列表</a>
        </div>
    </div>
</div>
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins animated fadeInDown">
        <div class="ibox-content" id="step-box">

            <div class="panel panel-default">
                <div class="panel-heading">
                    <b class="text step-title">新闻</b>
                </div>
                <div class="panel-body">
                    <form class="form-horizontal" name="itemForm" id="itemForm" role="form">
                        <input value="${news.id!}" name="id" type="hidden">
                        <div class="form-group">
                            <label class="col-sm-1 control-label">新闻标题：</label>
                            <div class="col-sm-7">
                                <input name="title" class="form-control" type="text" maxlength='30' value="${news.title!}" placeholder="请输入新闻标题" aria-required="true" required="required">
                            </div>
                         </div>
                         
                         <div class="form-group">
                            <label class="col-sm-1 control-label">新闻类型：</label>
                            <div class="col-sm-1">
                                <select name="newsType" id="newsType" class="form-control">
                                    <option value="1" ${news.newsType==1?"selected"}>政治</option>
                                    <option value="2" ${news.newsType==2?"selected"}>公示</option>
                                    <option value="3" ${news.newsType==3?"selected"}>民生</option>
                                </select>
                            </div>
                            <label class="col-sm-1 control-label">新闻状态：</label>
                            <div class="col-sm-1">
                              <select name="newsStatus" id="newsStatus" class="form-control">
                                    <option value="1" ${news.newsStatus==1?"selected"}>普通</option>
                                    <option value="2" ${news.newsStatus==2?"selected"}>置顶</option>
                                </select>
                            </div>
                             <label class="col-sm-1 control-label">新闻来源：</label>
                            <div class="col-sm-3">
                               <input name="source" class="form-control" type="text" maxlength='30' value="${news.source!'本站'}" placeholder="请输入新闻来源" aria-required="true" required="required">
                            </div>
                            
                         </div>

                        <div class="form-group">
                            <label for="guide" class="col-sm-1 control-label">封面图片：</label>
                            <div class="col-sm-11">
                            <input id="cover" name="cover" type="hidden"  value="${news.cover!'/images/nopic.jpg'}">
								<div style="width: 230px; height: 220px;">
									<img id="photo"
										src="${news.cover!'/images/nopic.jpg'}" alt="封面照片"
										style="width: 100%; height: 100%">
								</div>
								<button type="button" class="btn btn-primary"
									data-toggle="modal" data-target="#uploadModal"
									style="width: 230px; margin-top: 20px;">上传照片</button>
							</div>

							
						</div>

                        <div class="form-group">
                            <label for="description" class="col-sm-1 control-label">新闻摘要：</label>
                            <div class="col-sm-11">
                                <textarea id="description" name="description" cols="100" rows="10"   style="resize: none;" >${news.description!}</textarea>
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="material" class="col-sm-1 control-label">新闻内容：</label>
                            <div class="col-sm-11">
                                <textarea id="content" name="content" hidden="hidden" >${news.content!}</textarea>
                                <div id="contentEditer">
                                    <p>${news.content!}</p>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>

                <div class="panel-footer">
                    <div class="col-sm-offset-3 clearfix">
                        <div class="mt5 mb5 block col-sm-3">
                            <a href="index" class="btn btn-white btn-block"><i class="fa fa-times"></i>&ensp;取消</a>
                        </div>
                        <div class="mt5 mb5 block col-sm-3">
                            <button id="doSubmit" class="btn btn-primary btn-block"><i class="fa fa-check"></i>&ensp;保存</button>
                        </div>
                    </div>
                </div>

            </div>

        </div>

    </div>


</div>

<!-- 上传dialog -->
<div class="modal fade" id="uploadModal" tabindex="-1" role="dialog">
	<div class="modal-dialog" role="document">
		<div class="modal-content">
			<div class="modal-header">
				<h5 class="modal-title" id="uploadModalLabel">
					上传照片
					<button type="button" class="close" data-dismiss="modal"
						aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
				</h5>
			</div>
			<div class="modal-body">
				 <input type="file" class="form-control" id="userImgUploader" name="files" data-max-file-count="5" multiple="multiple">
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
			</div>
		</div>
	</div>
</div>
<!-- 上传dialog -->

<% } %>
<script type="text/javascript">
	//页面JS调用
	require([ 'news/newsInfo' ], function(newsInfo) {
		newsInfo.save();
	});
</script>